{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Calculating Rayleigh Reflectance using py6S "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Adapted from [Robin's Blog](http://blog.rtwilson.com/calculating-rayleigh-reflectance-using-py6s/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%pylab inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from Py6S import *\n",
    "\n",
    "s = SixS()\n",
    "\n",
    "s.altitudes.set_sensor_satellite_level()\n",
    "s.altitudes.set_target_sea_level()\n",
    "s.aero_profile = AeroProfile.PredefinedType(AeroProfile.NoAerosols)\n",
    "s.atmos_profile = AtmosProfile.PredefinedType(AtmosProfile.NoGaseousAbsorption)\n",
    "\n",
    "wavelengths = np.arange(0.3, 1.0, 0.05)\n",
    "rayleigh_refl = []\n",
    "\n",
    "for wv in wavelengths:\n",
    "    s.wavelength = Wavelength(wv)\n",
    "    s.run()\n",
    "\n",
    "    rayleigh_refl.append(s.outputs.atmospheric_intrinsic_reflectance)\n",
    "rayleigh_refl = np.array(rayleigh_refl)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.plot(wavelengths, rayleigh_refl, 'x-', label='Rayleigh Reflectance')\n",
    "plt.grid()\n",
    "plt.xlabel('Wavelength ($\\mu m$)')\n",
    "plt.ylabel('Rayleigh Reflectance (no units)')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
